import 'package:flutter/material.dart';
import 'package:loan_market/confit/screen_adapter.dart';
import 'package:url_launcher/url_launcher.dart';

class MePages extends StatefulWidget {
  @override
  _MePagesState createState() => _MePagesState();
}

class _MePagesState extends State<MePages> {
  //打开外部浏览器
  _openBrower(String url) async {
    // const url = 'https://flutter.dev';
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }

  }

  @override
  Widget build(BuildContext context) {
    ScreenAdapter.init(context);
    return Scaffold(
      appBar: AppBar(
        automaticallyImplyLeading: false,
        elevation: 0.0,
        backgroundColor: Color(0xFF2F7BD9),
        brightness: Brightness.light,
        title: Text(
          'Saya',
          textAlign: TextAlign.center,
          style: TextStyle(
            color: Color(0xFF333333),
            fontWeight: FontWeight.w500,
            fontSize: ScreenAdapter.size(40),
          ),
        ),
      ),
      backgroundColor: Color(0xFFF6F6F6),
      body: Container(
        child: Column(
          children: <Widget>[
            Container(
              color: Color(0xFFFFFFFF),
              height: ScreenAdapter.height(285),
              width: double.infinity,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    child: ClipOval(
                      child: Image.asset(
                        'images/avatar.png',
                        fit: BoxFit.cover,
                        width: ScreenAdapter.width(152),
                        height: ScreenAdapter.width(152),
                      ),
                    ),
                  ),
                  SizedBox(height: ScreenAdapter.height(16),),
                  Container(
                    child: Text('Segera mendarat', style: TextStyle(
                      fontSize: ScreenAdapter.size(40),
                      color: Color(0xFF101010)
                    ),),
                  ),
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: ScreenAdapter.height(25)),
              height: ScreenAdapter.height(400),
              color: Color(0xFFFFFFFF),
              child: ListView(
                physics: const NeverScrollableScrollPhysics(),
                children: <Widget>[
                  Container(
                    child: ListTile(
                      leading: Image.asset('images/privacy.png', height: ScreenAdapter.width(60), width: ScreenAdapter.width(60), fit: BoxFit.fill),
                      title: Text('Kontraknya',
                          style: TextStyle(
                              fontSize: ScreenAdapter.size(30.0),
                              color: Color(0xFF474646))),
                      onTap: () {
                        _openBrower('https://www.currydc.com/privacy-policy/index.html');
                      }
                    ),
                  ),
                  Divider(height: 1, color: Color(0xFFEEEEEE),),
                  Container(
                    child: ListTile(
                      leading: Image.asset('images/instructions.png', height: ScreenAdapter.width(60), width: ScreenAdapter.width(60), fit: BoxFit.fill),
                      title: Text('Panduan instruksi',
                          style: TextStyle(
                              fontSize: ScreenAdapter.size(30.0),
                              color: Color(0xFF474646))),
                      onTap: () {
                        _openBrower('https://www.currydc.com/privacy-policy/panduan_instruksi.html');
                      }
                    ),
                  ),
                  Divider(height: 1, color: Color(0xFFEEEEEE),),
                  Container(
                    child: ListTile(
                      leading: Image.asset('images/contact.png', height: ScreenAdapter.width(60), width: ScreenAdapter.width(60), fit: BoxFit.fill,),
                      title: Text('Hubungi kami',
                          style: TextStyle(
                              fontSize: ScreenAdapter.size(30.0),
                              color: Color(0xFF474646))),
                      onTap: () {
                        _openBrower('https://www.currydc.com/privacy-policy/hubungi_kami.html');
                      }
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
